package com.example.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;

//发送
@Service
public class Sender {

    private final RabbitTemplate rabbitTemplate;


    public Sender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public String send(String message){
        String context = message.concat("at")+new Date();
        rabbitTemplate.convertAndSend("helloQueue",context);
        return "Message '".concat(context).concat("' sent to MQ successfully");
    }
}
